home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Dogs / Multimedia Dogs v2.0.iso / pc / demos / petdisc / mmpets1d.exe / MMPETS1D.DXR / 00202_Breed handlers.ls < prev    next >
Encoding:
Text File  |  1995-10-06  |  11.0 KB  |  366 lines

  1. global gCDvolume, gCPU, gBreedDatabase, gBreedDatabaseCount, gBreedDatabaseByGroup, gBreedJumpIndex, gBreedCameFromFetch, gpBreedNameSprite, gpBreedSmallSprite, gpBreedBigSprite, gpBreedVideoSprite, gpBreedTextSprite, gpBreedVideoIsOn, gpBreedBigIsLoaded, gpBreedVideoIsLoaded, gpBreedPanelContents, gpBreedFilePath, gpBreedAudioChannel, gpSelectionWindow, gpBreedIndex, gpBreedIndexInGroup, gpBreedGroupIndex, gpBreedIndexList, gpBreedMarker, gpBreedBackgroundCastnum, gpBreedSmallCastnum, gpBreedBigCastnum, gpBreedNameCastnum, gpBreedTextCastnum, gpBreedVideoCastnum, gpBreedSoundFile, gpBreedProfileArtSprite, gpBreedProfileTrackSprite, gpBreedProfileMarkerSprite, gpBreedProfileFetchSprite, gpBreedProfileToggleSprite, gpBreedProfileIsLoaded
  2.  
  3. on initBreeds
  4.   set gpBreedNameSprite to 45
  5.   set gpBreedSmallSprite to 46
  6.   set gpBreedBigSprite to 47
  7.   set gpBreedVideoSprite to 48
  8.   set gpBreedTextSprite to 22
  9.   set gpBreedProfileArtSprite to 23
  10.   set gpBreedProfileTrackSprite to 24
  11.   set gpBreedProfileMarkerSprite to 25
  12.   set gpBreedProfileFetchSprite to 33
  13.   set gpBreedProfileToggleSprite to 41
  14.   set gpBreedVideoIsOn to 0
  15.   set gpBreedBigIsLoaded to 0
  16.   set gpBreedVideoIsLoaded to 0
  17.   set gpBreedProfileIsLoaded to 0
  18.   set gBreedCameFromFetch to 0
  19.   set gpBreedMarker to "breeds"
  20.   set gpBreedAudioChannel to 1
  21.   set gpBreedBackgroundCastnum to the number of cast "BreedHolder.bkg"
  22.   set gpBreedNameCastnum to the number of cast "BreedHolder.nam"
  23.   set gpBreedTextCastnum to the number of cast "BreedHolder.txt"
  24.   set gpBreedSmallCastnum to the number of cast "BreedHolder.sml"
  25.   set gpBreedBigCastnum to the number of cast "BreedHolder.big"
  26.   set gpBreedVideoCastnum to the number of cast "BreedHolder.mov"
  27.   set gBreedJumpIndex to getAt(getAt(gBreedDatabaseByGroup, 1), 1)
  28.   set gpBreedIndex to -1
  29. end
  30.  
  31. on enterBreed
  32.   setHelpContext(getBreedMarker())
  33.   loadBreedByIndex(gBreedJumpIndex)
  34.   set gBreedCameFromFetch to 0
  35. end
  36.  
  37. on exitBreed
  38.   closeSelectionMIAW()
  39.   sound stop gpBreedAudioChannel
  40.   disableBreedPuppets()
  41.   showAllSprites()
  42. end
  43.  
  44. on getBreedMarker
  45.   return gpBreedMarker
  46. end
  47.  
  48. on loadBreedByIndex theIndex
  49.   clearBreedBooleans()
  50.   set theRecord to getBreedRecord(theIndex)
  51.   set theCode to getFieldBreedCode(theRecord)
  52.   set theGroup to getFieldGroupCode(theRecord)
  53.   set oldIndex to gpBreedIndex
  54.   set gpBreedIndex to theIndex
  55.   set gBreedJumpIndex to theIndex
  56.   set gpBreedGroupIndex to findPos(gBreedDatabaseByGroup, theGroup)
  57.   set gpBreedIndexList to getAt(gBreedDatabaseByGroup, gpBreedGroupIndex)
  58.   set gpBreedIndexInGroup to getPos(gpBreedIndexList, theIndex)
  59.   if gCPU = #mac then
  60.     set gpBreedFilePath to gCDvolume & ":data:breeds:" & theGroup & ":" & theCode & ":" & theCode
  61.   else
  62.     set gpBreedFilePath to gCDvolume & "\data\breeds\" & theGroup & "\" & theCode & "\" & theCode
  63.   end if
  64.   hideBreedElements()
  65.   setBreedGroupArt(theGroup)
  66.   if theIndex = oldIndex then
  67.     putDebug("Breed" && theIndex && "is already loaded.")
  68.   else
  69.     relink(gpBreedNameCastnum, gpBreedFilePath & "1.pic")
  70.     importTextInto(gpBreedTextCastnum, gpBreedFilePath & "2.txt")
  71.     relink(gpBreedSmallCastnum, gpBreedFilePath & "3.pic")
  72.   end if
  73.   set gpBreedSoundFile to gpBreedFilePath & "7.aif"
  74.   enableBreedPuppets()
  75.   showBreedElements()
  76. end
  77.  
  78. on clearBreedBooleans
  79.   set gpBreedVideoIsOn to 0
  80.   set gpBreedBigIsLoaded to 0
  81.   set gpBreedVideoIsLoaded to 0
  82.   set gpBreedProfileIsLoaded to 0
  83. end
  84.  
  85. on hideBreedElements
  86.   sound stop gpBreedAudioChannel
  87.   hideSprite(gpBreedNameSprite)
  88.   hideSprite(gpBreedVideoSprite)
  89.   QTstop(gpBreedVideoSprite)
  90.   hideSprite(gpBreedSmallSprite)
  91.   hideSprite(gpBreedBigSprite)
  92.   hideSprite(gpBreedTextSprite)
  93.   hideSprite(gpBreedProfileArtSprite)
  94.   hideSprite(gpBreedProfileToggleSprite)
  95.   hideSprite(gpBreedProfileToggleSprite + 1)
  96.   hideBreedProfileMarkers()
  97.   hideBreedFetchMarkers()
  98.   updateStage()
  99. end
  100.  
  101. on showBreedElements
  102.   showSprite(gpBreedNameSprite)
  103.   showSprite(gpBreedSmallSprite)
  104.   if gBreedCameFromFetch = 1 then
  105.     showBreedProfile()
  106.   else
  107.     showBreedText()
  108.   end if
  109. end
  110.  
  111. on NextBreed
  112.   closeSelectionMIAW()
  113.   hideBreedElements()
  114.   if gpBreedIndexInGroup < count(gpBreedIndexList) then
  115.     set theIndex to getAt(gpBreedIndexList, gpBreedIndexInGroup + 1)
  116.   else
  117.     set gpBreedGroupIndex to gpBreedGroupIndex + 1
  118.     if gpBreedGroupIndex > count(gBreedDatabaseByGroup) then
  119.       set gpBreedGroupIndex to 1
  120.     end if
  121.     set theIndex to getAt(getAt(gBreedDatabaseByGroup, gpBreedGroupIndex), 1)
  122.   end if
  123.   loadBreedByIndex(theIndex)
  124. end
  125.  
  126. on PrevBreed
  127.   closeSelectionMIAW()
  128.   hideBreedElements()
  129.   if gpBreedIndexInGroup > 1 then
  130.     set theIndex to getAt(gpBreedIndexList, gpBreedIndexInGroup - 1)
  131.   else
  132.     set gpBreedGroupIndex to gpBreedGroupIndex - 1
  133.     if gpBreedGroupIndex < 1 then
  134.       set gpBreedGroupIndex to count(gBreedDatabaseByGroup)
  135.     end if
  136.     set gpBreedIndexList to getAt(gBreedDatabaseByGroup, gpBreedGroupIndex)
  137.     set theIndex to getAt(gpBreedIndexList, count(gpBreedIndexList))
  138.   end if
  139.   loadBreedByIndex(theIndex)
  140. end
  141.  
  142. on handleBreedSelectADog
  143.   QTstop(gpBreedVideoSprite)
  144.   updateStage()
  145.   hideSprite(gpBreedVideoSprite)
  146.   updateStage()
  147.   set theString to EMPTY
  148.   repeat with i = 1 to gBreedDatabaseCount - 1
  149.     set theString to theString & getFieldDisplayName(getAt(gBreedDatabase, i)) & RETURN
  150.   end repeat
  151.   set theString to theString & getFieldDisplayName(getAt(gBreedDatabase, gBreedDatabaseCount))
  152.   set theCallback to "tell the stage to loadBreedByIndex(theIndex)"
  153.   openSelectionMIAW(theString, "Select A Pet", theCallback)
  154. end
  155.  
  156. on handleBreedCamera
  157.   closeSelectionMIAW()
  158.   if the movieRate of sprite gpBreedVideoSprite > 0 then
  159.     hideSprite(gpBreedSmallSprite)
  160.     set gpBreedVideoIsOn to 0
  161.     QTstop(gpBreedVideoSprite)
  162.     updateStage()
  163.     hideSprite(gpBreedVideoSprite)
  164.     updateStage()
  165.   end if
  166.   if gpBreedBigIsLoaded = 0 then
  167.     relink(gpBreedBigCastnum, gpBreedFilePath & "4.pic")
  168.     set gpBreedBigIsLoaded to 1
  169.   end if
  170.   showSprite(gpBreedBigSprite)
  171.   updateStage()
  172.   showSprite(gpBreedSmallSprite)
  173. end
  174.  
  175. on handleBreedProjector
  176.   closeSelectionMIAW()
  177.   if the movieRate of sprite gpBreedVideoSprite <> 0 then
  178.     set gpBreedVideoIsOn to 0
  179.     QTstop(gpBreedVideoSprite)
  180.     updateStage()
  181.     hideSprite(gpBreedVideoSprite)
  182.     updateStage()
  183.   else
  184.     if gpBreedVideoIsLoaded = 0 then
  185.       relink(gpBreedVideoCastnum, gpBreedFilePath & "6.mov")
  186.       set gpBreedVideoIsLoaded to 1
  187.       updateStage()
  188.     end if
  189.     QTrewind(gpBreedVideoSprite)
  190.     showSprite(gpBreedVideoSprite)
  191.     updateStage()
  192.     QTplay(gpBreedVideoSprite)
  193.     set gpBreedVideoIsOn to 1
  194.     updateStage()
  195.     set the sound of cast gpBreedVideoCastnum to 1
  196.   end if
  197. end
  198.  
  199. on checkBreedVideo
  200.   if (gpBreedVideoIsOn = 1) and (the movieRate of sprite gpBreedVideoSprite = 0) and (the movieTime of sprite gpBreedVideoSprite > 1) then
  201.     hideSprite(gpBreedVideoSprite)
  202.     set gpBreedVideoIsOn to 0
  203.   end if
  204. end
  205.  
  206. on handleBreedAudio
  207.   if soundBusy(gpBreedAudioChannel) then
  208.     sound stop gpBreedAudioChannel
  209.   else
  210.     putDebug("playing soundFile" && gpBreedSoundFile)
  211.     sound playFile gpBreedAudioChannel, gpBreedSoundFile
  212.   end if
  213. end
  214.  
  215. on handleBreedSmallArea
  216.   handleBreedCamera()
  217. end
  218.  
  219. on handleBreedBigArea
  220.   hideSprite(gpBreedBigSprite)
  221. end
  222.  
  223. on handleBreedVideoArea
  224.   QTstop(gpBreedVideoSprite)
  225.   updateStage()
  226.   hideSprite(gpBreedVideoSprite)
  227.   updateStage()
  228. end
  229.  
  230. on handleBreedText
  231.   if gpBreedPanelContents = #text then
  232.     showBreedProfile()
  233.   else
  234.     showBreedText()
  235.   end if
  236. end
  237.  
  238. on showBreedText
  239.   hideBreedProfileMarkers()
  240.   hideSprite(gpBreedProfileToggleSprite)
  241.   hideSprite(gpBreedProfileArtSprite)
  242.   showSprite(gpBreedTextSprite)
  243.   set gpBreedPanelContents to #text
  244. end
  245.  
  246. on showBreedProfile
  247.   if gpBreedProfileIsLoaded = 0 then
  248.     set gpBreedProfileIsLoaded to 1
  249.     set profileList to getFieldProfile(getAt(gBreedDatabase, gpBreedIndex))
  250.     set fetchList to getFetchValueList()
  251.     set deltaH to the width of sprite gpBreedProfileTrackSprite / 4
  252.     set numCriteria to 8
  253.     putDebug("profileList =" && profileList)
  254.     putDebug("fetchList   =" && fetchList)
  255.     repeat with i = 1 to numCriteria
  256.       set theValue to getAt(profileList, i)
  257.       set theLocH to the locH of sprite gpBreedProfileTrackSprite + ((theValue - 1) * deltaH)
  258.       set the locH of sprite (gpBreedProfileMarkerSprite + i - 1) to theLocH
  259.       set theValue to getAt(fetchList, i)
  260.       if theValue > 0 then
  261.         set theLocH to the locH of sprite gpBreedProfileTrackSprite + ((theValue - 1) * deltaH)
  262.         set the locH of sprite (gpBreedProfileFetchSprite + i - 1) to theLocH
  263.         next repeat
  264.       end if
  265.       set the locH of sprite (gpBreedProfileFetchSprite + i - 1) to -100
  266.     end repeat
  267.     updateStage()
  268.   end if
  269.   hideSprite(gpBreedTextSprite)
  270.   showSprite(gpBreedProfileArtSprite)
  271.   showBreedProfileMarkers()
  272.   showSprite(gpBreedProfileToggleSprite)
  273.   set gpBreedPanelContents to #profile
  274. end
  275.  
  276. on toggleBreedFetchMarkers
  277.   showBreedFetchMarkers()
  278.   showSprite(gpBreedProfileToggleSprite + 1)
  279.   updateStage()
  280.   delayTicks(60)
  281.   repeat while the stillDown
  282.     nothing()
  283.   end repeat
  284.   hideBreedFetchMarkers()
  285.   hideSprite(gpBreedProfileToggleSprite + 1)
  286.   updateStage()
  287. end
  288.  
  289. on showBreedProfileMarkers
  290.   repeat with i = 0 to 7
  291.     showSprite(gpBreedProfileMarkerSprite + i)
  292.   end repeat
  293. end
  294.  
  295. on hideBreedProfileMarkers
  296.   repeat with i = 0 to 7
  297.     hideSprite(gpBreedProfileMarkerSprite + i)
  298.   end repeat
  299. end
  300.  
  301. on showBreedFetchMarkers
  302.   repeat with i = 0 to 7
  303.     showSprite(gpBreedProfileFetchSprite + i)
  304.   end repeat
  305. end
  306.  
  307. on hideBreedFetchMarkers
  308.   repeat with i = 0 to 7
  309.     hideSprite(gpBreedProfileFetchSprite + i)
  310.   end repeat
  311. end
  312.  
  313. on enableBreedPuppets
  314.   repeat with i = 0 to 7
  315.     safePuppetSprite(gpBreedProfileMarkerSprite + i, 1)
  316.     safePuppetSprite(gpBreedProfileFetchSprite + i, 1)
  317.   end repeat
  318. end
  319.  
  320. on disableBreedPuppets
  321.   repeat with i = 0 to 7
  322.     puppetSprite(gpBreedProfileMarkerSprite + i, 0)
  323.     puppetSprite(gpBreedProfileFetchSprite + i, 0)
  324.   end repeat
  325. end
  326.  
  327. on setBreedGroupArt theGroupCode
  328.   if gCPU = #mac then
  329.     set theFile to gCDvolume & ":data:breeds:" & theGroupCode & ":aabkg.pic"
  330.   else
  331.     set theFile to gCDvolume & "\data\breeds\" & theGroupCode & "\aabkg.pic"
  332.   end if
  333.   relink(gpBreedBackgroundCastnum, theFile)
  334.   updateStage()
  335. end
  336.  
  337. on setBreedBackground theIndex
  338.   set theRecord to getAt(gBreedDatabase, theIndex)
  339.   set theGroupCode to getFieldGroupCode(theRecord)
  340.   if gCPU = #mac then
  341.     set theFile to gCDvolume & ":data:breeds:" & theGroupCode & ":aabkg.pic"
  342.   else
  343.     set theFile to gCDvolume & "\data\breeds\" & theGroupCode & "\aabkg.pic"
  344.   end if
  345.   relink(gpBreedBackgroundCastnum, theFile)
  346. end
  347.  
  348. on handleBreedPrinter
  349.   set theAnswer to confirm("Would you like to print the information for this pet?")
  350.   if theAnswer = 0 then
  351.     exit
  352.   end if
  353.   waitCursor()
  354.   puppetSound("printing.aif")
  355.   updateStage()
  356.   set theName to getFieldDisplayName(getAt(gBreedDatabase, gpBreedIndex))
  357.   set theTitle to theName && "- Pet Information"
  358.   if gpBreedBigIsLoaded = 0 then
  359.     relink(gpBreedBigCastnum, gpBreedFilePath & "4.pic")
  360.     set gpBreedBigIsLoaded to 1
  361.   end if
  362.   printReport(theTitle, gpBreedSmallCastnum, gpBreedTextCastnum)
  363.   printPICT(the picture of cast gpBreedBigCastnum, theName)
  364.   pointerCursor()
  365. end
  366.